<template>
    <ul class="test_ul" v-if="showList">
      <li class="test_li" v-for='v in testList' @click="selectTest(v.id)">
        <div class="img_grp ">
          <img v-lazy="v.pic" alt="">
          <div class="test_num">
            {{v.join_count}}人已测
          </div>
        </div>
        <div class="content_grp">
          <div class="article_title">
            {{v.title}}
          </div>
          <div class="pay_type">
            <span v-if="v.is_free==0">￥<span class="money">{{v.price}}</span></span>
            <span v-if="v.is_free==1">免费</span>
          </div>

          <div class="tag_grp">
            <span class="tag major" v-if="v.is_profession ==1">专业</span>
            <span class="tag interest" v-if="v.is_profession ==2">趣味</span>
            <span class="tag" v-if="nid==1 || !nid">{{v.cat_name}}</span>
          </div>
        </div>
      </li>
    </ul>
</template>

<script>
  export default {
    name: 'TestList',
    props: {
      testList: Array,
      nid:Number
    },

    computed: {
      showList() {
        return this.testList.length
      }
    },
    methods:{
      selectTest(id){
        this.$router.push({path:'/testRule/' + id + ''})
      }
    }

  }
</script>

<style scoped>
  .test_ul{

  }
  li {
    width: 100%;
    padding: 35px 20px;
    background-color: white;
    border-bottom: solid 1px #ededef;
    margin-bottom: 20px;

  }

  .test_li {
    height: 175px;

  }

  .test_li .img_grp {
    width: 158px;
    height: 100px;
    border: solid 1px #ededef;
    margin-right: 30px;
    float: left;
  }

  .img_grp .test_num {
    position: absolute;
    left: 0;
    bottom: 0;
    font-size: 20px;
    width: 100%;
    height: 34px;
    opacity: 0.4;
    line-height: 36px;
    background: black;
    color: white;
    text-align: center;
  }

  .test_li .article_title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    width: 430px;
    height: 40px;
    font-size: 30px;
  }

  .content_grp {
    position: relative;
  }

  .pay_type {
    text-align: right;
    position: absolute;
    right: 0;
    top: 30px;
    height: 22px;
  }

  .pay_type span {
    font-size: 24px;
    color: #ff6d00;
  }

  .pay_type .money {
    font-size: 30px;
  }

  .tag_grp {
    height: 40px;
    margin-top: 12px;
  }

  .tag {
    font-size: 24px;
    border-radius: 20px;
    border: solid 1px #c5c5c7;
    padding: 6px 12px;
    color: #c5c5c7;
    margin-right: 10px;

  }

  .major {
    background: #059692;
    color: white;
    border-color: #059692;
  }

  .interest {
    border-color: #059692;
    color: #059692;
  }
</style>
